package com.ruoyi.basedocument.service.impl;

import java.util.List;

import com.ruoyi.basedocument.domain.BomAsscategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.basedocument.mapper.BomBaseunitMapper;
import com.ruoyi.basedocument.domain.BomBaseunit;
import com.ruoyi.basedocument.service.IBomBaseunitService;

/**
 * 计量单位Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-09-23
 */
@Service
public class BomBaseunitServiceImpl implements IBomBaseunitService 
{
    @Autowired
    private BomBaseunitMapper bomBaseunitMapper;

    /**
     * 查询计量单位
     * 
     * @param id 计量单位主键
     * @return 计量单位
     */
    @Override
    public BomBaseunit selectBomBaseunitById(String id)
    {
        return bomBaseunitMapper.selectBomBaseunitById(id);
    }

    /**
     * 查询计量单位列表
     * 
     * @param bomBaseunit 计量单位
     * @return 计量单位
     */
    @Override
    public List<BomBaseunit> selectBomBaseunitList(BomBaseunit bomBaseunit)
    {
        return bomBaseunitMapper.selectBomBaseunitList(bomBaseunit);
    }

    /**
     * 查询计量单位列表
     *
     * @param bomBaseunit 计量单位
     * @return 计量单位
     */
    @Override
    public List<BomBaseunit> selectBomBaseunitList2(BomBaseunit bomBaseunit)
    {
        return bomBaseunitMapper.selectBomBaseunitList2(bomBaseunit);
    }

    /**
     * 新增计量单位
     * 
     * @param bomBaseunit 计量单位
     * @return 结果
     */
    @Override
    public int insertBomBaseunit(BomBaseunit bomBaseunit)
    {
        BomBaseunit obj = new BomBaseunit();
        obj.setBaseunitnumber(bomBaseunit.getBaseunitnumber());
        List<BomBaseunit> objs = selectBomBaseunitList2(obj);
        if(objs!=null&&objs.size()!=0){
            throw new RuntimeException("编码已存在:"+bomBaseunit.getBaseunitnumber());
        }
        return bomBaseunitMapper.insertBomBaseunit(bomBaseunit);
    }

    /**
     * 修改计量单位
     * 
     * @param bomBaseunit 计量单位
     * @return 结果
     */
    @Override
    public int updateBomBaseunit(BomBaseunit bomBaseunit)
    {
        return bomBaseunitMapper.updateBomBaseunit(bomBaseunit);
    }

    /**
     * 批量删除计量单位
     * 
     * @param ids 需要删除的计量单位主键
     * @return 结果
     */
    @Override
    public int deleteBomBaseunitByIds(String[] ids)
    {
        return bomBaseunitMapper.deleteBomBaseunitByIds(ids);
    }

    /**
     * 删除计量单位信息
     * 
     * @param id 计量单位主键
     * @return 结果
     */
    @Override
    public int deleteBomBaseunitById(String id)
    {
        return bomBaseunitMapper.deleteBomBaseunitById(id);
    }
}
